POV-Ray : Newsgroups : povray.general : Determining rotation : Re: Determining rotation Server Time
30 Jul 2024 22:24:10 EDT (-0400)
  Re: Determining rotation  
From: Chris B
Date: 11 May 2008 05:40:56
Message: <4826bf28$1@news.povray.org>
"Tail Kinker" <the### [at] gmailcom> wrote in message 
news:482635fd@news.povray.org...
>I am working with limbs still.  Given a point A, a given distance (r) from 
>the origin, how would I determine the angles to rotate an object at <0, r, 
>0> to match A?  I've beaten my head against this one for some weeks now, 
>and my math skills are not up to the task.

This can get quite complicated, depending on precisely what you want to do. 
Particularly when posing limbs where you may need to work in a sequence 
that's different from the conventional X-Y-Z rotation sequence.

If you aren't interested in the orientation of the object around its own 
axis (you usually are with limbs), you can get from <0,r,0> to anywhere with 
one X rotation followed by one Y rotation (anywhere where vlength(A)=r).

You can work out the angles, one at a time, by taking the point that you get 
by projecting point A onto the YZ-plane (project a line through A and 
through the YZ-plane at right angles). This point will be at <0,A.y,A.z>. 
You can now use trigonometry to work out the two angles you're interested 
in, or you can use the VAngleD() function from math.inc (you'll obviously 
need to take care over angles in the different quadrants).

If you are interested in the final orientation of the limb (which you 
probably are) then getting a single X-Y-Z rotation gets quite a bit more 
complicated. A simpler alternative is to apply the reverse rotations you get 
from the previous calculation to an orientation vector (a normal to Vector 
A) to bring it back onto the XZ-plane. You can then use VAngleD() to work 
out a Y rotation that can be applied to the object before you apply the X-Y 
rotations from the previous calculation to the limb object. By doing this 
you end up with a Y-X-Y rotation sequence, rather than an X-Y-Z rotation 
sequence, so you'll need to apply two POV-Ray rotation statements rather 
than one.

Hope that helps unlock the particular bits of grey matter that beating your 
head didn't :-)

Regards,
Chris B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.